<?php

declare(strict_types=1);

namespace App\Request\My;


use Hyperf\Context\Context;
use Hyperf\Validation\Request\FormRequest;

class BindPhonePasswordRequest1 extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    protected array $scenes = [
        1 => ['account', 'code'],// 1
        2 => ['account'], // 2
        3 => ['password', 'r_password'], // 3
        4 => ['account', 'password', 'code'], // 4
    ];


    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'type' => 'required|in:1,2,3,4',
            'account' => 'required',
            'code' => 'required',
            'password' => 'required',
            'r_password' => 'required|same:password'
        ];
    }

    public function messages(): array
    {
        $language = Context::get('language');
        if ($language == 'zh-zn') {
            return [
                'type.required' => '类型不能为空',
                'type.in' => '类型只能是1,2,3,4',
                'account.required' => '手机号不能为空',
                'code.required' => '验证码不能为空',
                'password.required' => '密码不能为空',
                'r_password.required' => '确认密码不能为空',
                'r_password.same' => '两次密码不一致',
            ];
        } elseif ($language == 'zh-hk') {
            return [
                'type.required' => '類型不能為空',
                'type.in' => '類型只能是1,2,3,4',
                'account.required' => '手機號不能為空',
                'code.required' => '驗證碼不能為空',
                'password.required' => '密碼不能為空',
                'r_password.required' => '確認密碼不能為空',
                'r_password.same' => '兩次密碼不一致',
            ];
        } else {
            return [
                'type.required' => 'Type is required',
                'type.in' => 'Type must be 1,2,3,4',
                'account.required' => 'Account is required',
                'code.required' => 'Code is required',
                'password.required' => 'Password is required',
                'r_password.required' => 'Confirm password is required',
                'r_password.same' => 'The two passwords are inconsistent',
            ];
        }
    }

}
